package com.atguigu.gmall.weball.controller;
import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.feign.order.OrderFeign;
import com.google.common.collect.Lists;
import java.math.BigDecimal;

import com.atguigu.gmall.model.vo.order.CartItemForOrderVo;
import com.atguigu.gmall.model.vo.order.OrderConfirmVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * @author A
 * @version 1.0
 * @description: TODO
 * @date 2025/9/12 15:33
 */
@Controller
public class OrderController {
    @Autowired
    OrderFeign orderFeign;
    @GetMapping("/trade.html")
    public String ConfirmOrder(Model model){
        //detailArrayList  detail:{imgUrl:"",skuName:"",orderPrice:"",skuNum:""}
        //totalNum
        //totalAmount
        //userAddressList
        //tradeNo
        Result<OrderConfirmVo> orderConfirmVoResult = orderFeign.orderList();
        if (orderConfirmVoResult.getCode() == 200){
            OrderConfirmVo orderConfirmVo = orderConfirmVoResult.getData();
            model.addAttribute("detailArrayList",orderConfirmVo.getDetailArrayList());
            model.addAttribute("totalNum",orderConfirmVo.getTotalNum());
            model.addAttribute("totalAmount",orderConfirmVo.getTotalAmount());
            model.addAttribute("userAddressList",orderConfirmVo.getUserAddressList());
            model.addAttribute("tradeNo",orderConfirmVo.getTradeNo());
        }

        return "order/trade";
    }
}
